package com.example.iread.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.example.iread.R;

import java.util.Objects;

public class InfoEditorActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_info_editor);

        View btn_info_editor_close = findViewById(R.id.btn_info_editor_close);
        btn_info_editor_close.setOnClickListener(v -> {
            setResult(RESULT_CANCELED);
            finish();
        });

        String nickname = Objects.requireNonNull(getIntent().getExtras()).getString("nickname");

        EditText et_edit_name = findViewById(R.id.et_edit_name);
        et_edit_name.setText(nickname);

        View btn_save_edit_name = findViewById(R.id.btn_save_edit_name);
        btn_save_edit_name.setOnClickListener(v -> {
            Intent intent = new Intent();
            intent.putExtra("nickname", et_edit_name.getText().toString());
            setResult(RESULT_OK, intent);
            finish();
        });
    }
}